package com.sunwayworld.basemodule.business.batch.resource.impl;

import com.alibaba.fastjson.JSONObject;
import com.sunwayworld.basemodule.basedata.batchtype.bean.LimsBatchCategoryBean;
import com.sunwayworld.basemodule.business.batch.bean.LimsBatchBean;
import com.sunwayworld.basemodule.business.batch.validators.LimsBatchSubmitValidator;
import com.sunwayworld.framework.validator.data.annotation.ValidateDataWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.sunwayworld.basemodule.business.batch.resource.LimsBatchResource;
import com.sunwayworld.basemodule.business.batch.service.LimsBatchService;
import com.sunwayworld.framework.spring.annotation.GikamBean;
import com.sunwayworld.framework.log.annotation.Log;
import com.sunwayworld.framework.log.annotation.LogModule;
import com.sunwayworld.framework.log.annotation.LogType;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@LogModule("送检单")
@RestController
@GikamBean
public class LimsBatchResourceImpl implements LimsBatchResource {

    @Autowired
    private LimsBatchService limsBatchService;

    @Override
    public LimsBatchService getService() {
        return limsBatchService;
    }

    @Log(value = "新增送检单", type = LogType.INSERT)
    @Override
    @RequestMapping(method = RequestMethod.POST)
    public Long insert(RestJsonWrapperBean wrapper) {
        return getService().insert(wrapper);
    }

    @Override
    @ValidateDataWith(LimsBatchSubmitValidator.class)
    public void batchSubmit(RestJsonWrapperBean wrapper) {
        getService().submit(wrapper);
    }

    @Override
    public void batchApprove(RestJsonWrapperBean wrapper) {
        getService().batchApprove(wrapper);
    }

    @Override
    public void batchReject(RestJsonWrapperBean wrapper) {
        getService().batchReject(wrapper);
    }

    @Override
    public void submitById(Long id, RestJsonWrapperBean wrapper) {
        getService().submitById(id, wrapper);
    }

    @Override
    public LimsBatchBean selectForBatchDetailPage(Long id) {
        return getService().selectForBatchDetailPage(id);
    }

    @Override
    public JSONObject recallBatch(RestJsonWrapperBean jsonWrapperBean) {
        return getService().recallBatch(jsonWrapperBean);
    }

    @Override
    public LimsBatchCategoryBean batchCategory(RestJsonWrapperBean wrapperBean) {
        return getService().batchCategory(wrapperBean);
    }
}
